package hle.com;

import java.util.Stack;

public class MyQueue {
	Stack<Integer> instack = new Stack<>();
	Stack<Integer> outStack = new Stack<>();
	
	 /** Initialize your data structure here. */
    public MyQueue() {
    	
    }
    
    /** Push element x to the back of queue. */
    public void push(int x) {
    	instack.push(x);
    }
    
    /** Removes the element from in front of queue and returns that element. */
    public int pop() {
    	if (outStack.isEmpty()) {
			while (!instack.isEmpty()) {
				outStack.push(instack.pop());
			}
		}
    	return outStack.pop();
    }
    
    /** Get the front element. */
    public int peek() {
    	if (outStack.isEmpty()) {
			while (!instack.isEmpty()) {
				outStack.push(instack.pop());
			}
		}
    	return outStack.peek();
    }
    
    /** Returns whether the queue is empty. */
    public boolean empty() {
    	if (instack.isEmpty() && outStack.isEmpty()) {
			return true;
		}else {
			return false;
		}
    }
}
